package com.pgybook.db.entity.mapper;

import org.springframework.stereotype.Repository;
import com.pgybook.db.entity.domain.CityDistrict;
import com.pgybook.db.entity.domain.CityDistrictEx;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;

@Repository
public interface CityDistrictMapper {
    int countByExample(CityDistrictEx example);

    int deleteByExample(CityDistrictEx example);

    @Delete({
            "delete from citydistrict",
            "where CITYDISTRICTID = #{citydistrictid,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer citydistrictid);

    @Insert({
            "insert into citydistrict (CDNAME, CDCODE, ",
            "CITYID)",
            "values (#{cdname,jdbcType=VARCHAR}, #{cdcode,jdbcType=VARCHAR}, ",
            "#{cityid,jdbcType=INTEGER})"
    })
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "citydistrictid", before = false, resultType = Integer.class)
    int insert(CityDistrict record);

    int insertSelective(CityDistrict record);

    List<CityDistrict> selectByExample(CityDistrictEx example);

    @Select({
            "select",
            "CITYDISTRICTID, CDNAME, CDCODE, CITYID",
            "from citydistrict",
            "where CITYDISTRICTID = #{citydistrictid,jdbcType=INTEGER}"
    })
    @ResultMap("BaseResultMap")
    CityDistrict selectByPrimaryKey(Integer citydistrictid);

    int updateByExampleSelective(@Param("record") CityDistrict record, @Param("example") CityDistrictEx example);

    int updateByExample(@Param("record") CityDistrict record, @Param("example") CityDistrictEx example);

    int updateByPrimaryKeySelective(CityDistrict record);

    @Update({
            "update citydistrict",
            "set CDNAME = #{cdname,jdbcType=VARCHAR},",
            "CDCODE = #{cdcode,jdbcType=VARCHAR},",
            "CITYID = #{cityid,jdbcType=INTEGER}",
            "where CITYDISTRICTID = #{citydistrictid,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(CityDistrict record);
}
